<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/Validform_v4.0_min.js"></script>
<style type="text/css">
#apDiv1 {
	position: absolute;
	left: 660px;
	top: 729px;
	width: 179px;
	height: 38px;
	z-index: 1;
}
</style>
<div id="contener" _height="auto">
	<div class="left_menu">
		<?php $this->beginWidget('application.widget.site.classWidget'); ?>
		<?php $this->endWidget(); ?>
		<?php $this->beginWidget('application.widget.site.productWidget'); ?>
		<?php $this->endWidget(); ?>
	</div>
	<div class="main">
		<?php $this->beginWidget('application.widget.site.newWidget'); ?>
		<?php $this->endWidget(); ?>
		<div class="right_mainBox">
			<div class="right_mainBox_top"></div>
			<div class="mainContentBox">
				<form action="" method="post" class="payForm">
					<div class="memberBOX4"> <img src="images/buySTEP2.png" width="724" height="65" class="buySTEP"/>
						<table width="720" border="0" align="center" cellpadding="0" cellspacing="3">
							<tr>
								<th colspan="4" scope="col"> <strong>選擇收貨方式</strong></th>
							</tr>
							<tr>
								<td>  <strong>收貨人資料</strong></td>
								<td>&nbsp;</td>
								<td colspan="2">
									<p><br />
									</p>
								</td>
							</tr>
							<tr>
								<td width="100">   收件者</td>
								<td width="150">
									<input name="name" type="text" id="name" value="<?=$payinfo->name?>" size="15" datatype="realname" nullmsg="請輸入姓名！" errormsg="請輸入正確的姓名！" />
								</td>
								<td colspan="2">
									<label>
										<input type="radio" <?php if($payinfo->pre==1){?> checked="checked" <?php }?> id="pre1" value="1" name="pre">
										先生</label>
									<label>
										<input type="radio" <?php if($payinfo->pre==2){?> checked="checked" <?php }?> id="pre2" value="2" name="pre">
										小姐</label>
									<br>
								</td>
							</tr>
							<tr>
								<td>   電話</td>
								<td>
									<input name="phone" type="text" value="<?=$payinfo->phone?>" id="phone" size="15" datatype="s1-20" nullmsg="請輸入電話！" errormsg="請輸入正確的電話！" />									
								</td>
								<td width="110">E-mail </td>
								<td width="365">
									<input name="email" type="text" value="<?=$payinfo->email?>" id="email" size="22" datatype="e" nullmsg="請填入E-mail!" errormsg="請填寫正確的E-mail地址。" />
								</td>
							</tr>
							<tr>
								<td>   送貨地址</td>
								<td colspan="3">
									<input name="address" type="text" id="address" value="<?=$payinfo->address?>" size="61" datatype="s1-100" nullmsg="請輸入送貨地址！" errormsg="地址超長！" />
								</td>
							</tr>
						</table>
						<table width="720" border="0" cellpadding="0" cellspacing="3" id="table88">
							<tr>
								<th colspan="2" >選擇付款方式:</th>
							</tr>
							<tr>
								<td width="24">
									<input type="radio" name="paytype" id="paytype" <?php if($payinfo->paytype==1){?> checked="checked" <?php }?>  value="1" datatype="radio" nullmsg="請選擇付款方式！" />
								</td>
								<td width="687">ATM轉帳(海外客戶限使用網路ATM轉帳，以台幣支付)<span class="BLUE">(ATM轉帳說明)</span></td>
							</tr>
							<!--<tr>
							<td>
								<input type="radio" name="radio2" id="radio2" value="radio2" />
								<label for="radio2"></label>
							</td>
							<td>信用卡線上刷卡一次付清(可接受<span class="RED">VISA,Master,JCB,聯合信用卡,美國運通</span>)</td>
						</tr>
						<tr>
							<td>
								<input type="radio" name="radio3" id="radio3" value="radio3" />
								<label for="radio3"></label>
							</td>
							<td>信用卡紅利點數折抵刷卡金(限新光、萬泰、第一、渣打)<span class="BLUE">(紅利折抵說明)</span></td>
						</tr>
						<tr>
							<td>
								<input type="radio" name="radio4" id="radio4" value="radio4" />
								<label for="radio4"></label>
							</td>
							<td>7-11取貨付款<span class="BLUE">(24隔日取貨說明)</span></td>
						</tr>
						<tr>
							<td>
								<input type="radio" name="radio4" id="radio4" value="radio4" />
								<label for="radio4"></label>
							</td>
							<td>購物金折抵<span class="BLUE">(購物金折抵說明)</span></td>
						</tr>-->
						</table>
						<table width="720" border="0" cellpadding="0" cellspacing="3" id="table88">
							<tr>
								<th colspan="2">發票資訊:</th>
							</tr>
							<!--<tr>
								<td width="135">
									<input type="radio" name="receipttype" id="receipt_type1" <?php if($payinfo->receipttype==1){?> checked="checked" <?php }?> value="1" datatype="radio" nullmsg="請填寫發票資訊！" errormsg="請填寫發票資訊！" />
									兩聯式電子發票</td>
								<td width="576">買受人
									<input type="text" name="receiptfield1_1" id="receiptfield1_1" datatype="s0-20" ignore="ignore" errormsg="文案超長！" value="<?=$payinfo->receiptfield1_1?>" />
									可不填<span class="BLUE">(電子發票不隨貨寄出,揪贏網幫你對獎,詳見說明。)</span></td>
							</tr>-->
							<tr>
								<td>
									<input type="radio" name="receipttype" id="receipt_type3" <?php if($payinfo->receipttype==3){?> checked="checked" <?php }?> value="3" />
									<label for="radio3">兩聯式紙本發票</label>
								</td>
								<td>買受人
									<input type="text" name="receiptfield1_3" datatype="s0-20" ignore="ignore" errormsg="文案超長！"  id="receiptfield1_3" value="<?=$payinfo->receiptfield1_3?>" />
									可不填</td>
							</tr>
							<tr>
								<td>
									<input type="radio" name="receipttype" id="receipt_type2" <?php if($payinfo->receipttype==2){?> checked="checked" <?php }?> value="2" />
									<label for="radio2">兩聯式捐贈發票</label>
								</td>
								<td>捐贈單位:
									<select name="receiptfield1_2" id="receiptfield1_2">
										<option <?php if($payinfo->receiptfield1_2==1){?> selected="selected" <?php }?> value="1">財團法人伊甸基金會</option>
									</select>
								</td>
							</tr>							
							<tr>
								<td>
									<input type="radio" name="receipttype" id="receipt_type4" <?php if($payinfo->receipttype==4){?> checked="checked" <?php }?> value="4" />
									<label for="radio4">三聯式發票</label>
								</td>
								<td>統一編號
									<input type="text" name="receiptfield1_4" datatype="s0-20" ignore="ignore" errormsg="文案超長！"  id="receipt_field1_4" value="<?=$payinfo->receiptfield1_4?>" />
									<br />
									<br />
									發票抬頭
									<input type="text" name="receiptfield2" datatype="s0-22" ignore="ignore" errormsg="文案超長！"  id="receipt_field2" value="<?=$payinfo->receiptfield2?>" />
									<span class="BLUE">(限22個全形文用,若抬頭字數超過,請電洽客服人員處理)</span></td>
							</tr>
							
								<td colspan="2">依統一發票使用辦法規定:個人戶(二聯式)發票一經開立,不得任意更改或改開</td>
							<tr> </tr>
						</table>
					</div>
					<div id="apDiv1">
						<table width="140" height="46" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td>
									&nbsp;
								</td>
								<td>
									<input type="submit" name="button2" id="button2" value="下一步" />
								</td>
							</tr>
						</table>
					</div>
				</form>
			</div>
			<div class="right_mainBox_bottom"></div>
		</div>
	</div>
</div>
<script type="text/javascript">
$(function(){
	var showmsg=function(msg){//假定你的信息提示方法为showmsg， 在方法里可以接收参数msg，当然也可以接收到o及cssctl;
		if(msg!='通過資料驗證！'){
			alert(msg);
		}		
	}
	$(".payForm").Validform({
		tiptype:function(msg){
			showmsg(msg);
		},
		datatype:{//传入自定义datatype类型，可以是正则，也可以是函数（函数内可以获得两个参数）;
			"realname" : /^[\u4E00-\u9FA5]{2,6}$/,
		},
		callback:function(form){
			if(payCheck()){
				form.get(0).submit();
			}
		},
	});
})
function payCheck(){	
	var receipt_type = $('input[name="receipttype"]:checked').val();
	var field1 = document.getElementById('receiptfield1_4');
	var field2 = document.getElementById('receiptfield2');
	if(receipt_type==4){
		if(field1.value==''){
			alert('請填寫統一編號');
			field1.focus();
			return false;
		}
		if(field2.value==''){
			alert('請填寫發票抬頭');
			field2.focus();
			return false;
		}
	}
	return true;	
}
</script>